﻿using System;

namespace FBGraph.Async
{
    /// <summary>Defines a handler for an event that is fired when an error occurs during an asynchronous Graph API call.</summary>
    /// <param name="sender">The object that fired the event.</param>
    /// <param name="e">An instance of <see cref="FBGraphAsyncErrorEventArgs" /> containing information about the event.</param>
    public delegate void FBGraphAsyncErrorHandler(Object sender, FBGraphAsyncErrorEventArgs e);

    /// <summary>An <see cref="EventArgs" /> implementation that contains information about an error that occurred while making asynchronous Graph API requests.</summary>
    public class FBGraphAsyncErrorEventArgs : EventArgs
    {
        /// <summary>Initializes an instance of <see cref="FBGraphAsyncErrorEventArgs" /> with the specified <paramref name="uri" /> and <paramref name="exception" />.</summary>
        /// <param name="uri">The <see cref="Uri" /> that was being called when the error occurred.</param>
        /// <param name="exception">The <see cref="Exception" /> that was thrown.</param>
        public FBGraphAsyncErrorEventArgs(Uri uri, Exception exception)
        {
            this.Exception = exception;
            this.Uri = uri;
        }

        /// <summary>Gets the exception that was thrown.</summary>
        public Exception Exception { get; private set; }

        /// <summary>Gets the <see cref="Uri" /> that was being called when the error occurred.</summary>
        public Uri Uri { get; private set; }
    }
}